<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Promise跟setTimeout练习</title>
</head>

<body>
    <script type="text/javascript">
        const promise = new Promise((resolve, reject) => {
            console.log("执行顺序1")
            setTimeout(() => {
                console.log("宏任务里面返回微任务 fuilled状态2")
                resolve("resolve")
            })
        })
        promise.then((result) => {
            console.log("result结果执行3")
        })

        const p = new Promise(resolve => {
            console.log('同步执行2');
            resolve('同步执行2');
        }).then(tip => {
            console.log('then2_1', tip);
        }).then(tip => {
            console.log('then2_2', tip);
        });

        setTimeout(() => {
            p.then(tip => {
                console.log('then2_3', tip);
            })
        });

        const p2 = new Promise(resolve => {
            console.log('同步执行3');
            resolve('同步执行3');
        }).then(tip => {
            console.log('then3_1', tip);
        }).then(tip => {
            console.log('then3_2', tip);
        });

        setTimeout(() => {
            p2.then(tip => {
                console.log('then3_3', tip);
            })
        });
    </script>
</body>

</html>